from typing import Any, Optional
from pydantic import BaseModel

class ResponseModel(BaseModel):
    code: int = 200
    message: str = "success"
    data: Optional[Any] = None

    @classmethod
    def success(cls, data: Any = None, message: str = "success") -> dict:
        return {
            "code": 200,
            "message": message,
            "data": data
        }

    @classmethod
    def error(cls, code: int = 400, message: str = "error") -> dict:
        return {
            "code": code,
            "message": message,
            "data": None
        } 